<?php

namespace App;

use App\Http\Controllers\Api\WeChatThirdController;
use EasyWeChat\Factory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;



/**
 * App\AvailableUrl
 *
 * @property int $id
 * @property string $domain 域名记录
 * @property int $enterprise_id 所属企业
 * @property string $miniprogram_appid 授权方小程序appid
 * @property string $service_appid 授权方服务号appid
 * @property string $subscription_appid 授权方订阅号appid
 * @property string $wechatpay_mchid 授权方微信支付商户号
 * @property string $wechatpay_key 授权方微信支付秘钥
 * @property string $login_key 授权方微信登录秘钥
 * @property string $wechatpay_certificate_cert_name 授权方微信支付证书cert文件名
 * @property string $wechatpay_certificate_key_name 授权方微信支付证书key文件名
 * @property string|null $expire_date 服务到期时间
 * @property string $remark 备注
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\AvailableUrl onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereDomain($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereEnterpriseId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereExpireDate($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereLoginKey($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereMiniprogramAppid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereRemark($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereServiceAppid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereSubscriptionAppid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereWechatpayCertificateCertName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereWechatpayCertificateKeyName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereWechatpayKey($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\AvailableUrl whereWechatpayMchid($value)
 * @method static \Illuminate\Database\Query\Builder|\App\AvailableUrl withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\AvailableUrl withoutTrashed()
 * @mixin \Eloquent
 */
class AvailableUrl extends Model
{
    //
    use SoftDeletes;

    /**
     * @param $enterprise_id
     * @return mixed|string
     */
    public static function getAppid($enterprise_id){
        /** @var self $data */
        $data = self::whereEnterpriseId($enterprise_id)->orderByDesc('id')->first();
        return $data ? $data->miniprogram_appid : '';
    }
//    protected $hidden=[
//        'wechatpay_key',
//    ];

}
